package com.heima.wemadia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dto.WmMaterialDto;
import com.heima.wemadia.service.WmMaterialService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;


@RestController
@RequestMapping("/api/v1/material/")
public class WmMaterialController {

    @Resource
    private WmMaterialService wmMaterialService;
    @PostMapping(path = "/upload_picture")
    public ResponseResult uploadPic(MultipartFile multipartFile){
        return wmMaterialService.uploadPic(multipartFile);
    }

    @PostMapping(path = "/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto) {
        return wmMaterialService.list(dto);
    }


    @GetMapping("/del_picture/{id}")
    public ResponseResult deleteByImageId(@PathVariable("id") Long imageId){
        return wmMaterialService.deleteByImageId(imageId);
    }

    @GetMapping("/collect/{id}")
    public ResponseResult collectImages(@PathVariable("id") Long imageId){
        return wmMaterialService.collectImages(imageId);
    }

    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable("id") Long imageId){
        return wmMaterialService.cancelCollect(imageId);
    }
}
